package cn.itheima.controller;

import cn.itheima.domain.Items;
import cn.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/demo")
public class ControllerDemo {
    @Autowired
    private UserService service;

    @RequestMapping("/findAll/{id}")
    public
    String findDetail(@PathVariable("id") String id, Model model) {
        try {
            System.out.println(id);
            System.out.println("-------------------");
            List<Items> all = service.findAll();
            System.out.println(all);
            model.addAttribute("it", all);
            return "success";
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
